package edu.hendrix.grambler.grammars;

import edu.hendrix.grambler.Grammar;

public class SimpleMath extends edu.hendrix.grambler.Grammar {
    public SimpleMath() {
        super();
        addProduction("sum", new String[]{"sum", "sp", "op", "sp", "number"}, new String[]{"number"});
        addProduction("sp", new String[]{"\"\\s*\""});
        addProduction("op", new String[]{"'+'"}, new String[]{"'-'"});
        addProduction("number", new String[]{"\"\\d+\""});
    }

	public static Grammar makeGrammar1() {
		return Grammar.makeFrom("sum: number op number; op: '+'; number: number digit | digit; digit: '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'; ");
	}

	public static Grammar makeGrammar2() {
		return Grammar.makeFrom("sum: number op number; op: '+'; number: \"\\d+\"; ");
	}

	public static Grammar makeGrammar3() {
		return new SimpleMath();
	}
}

